package com.area.cth.service.impl;

import com.area.cth.mapper.DealMapper;
import com.area.cth.pojo.Deal;
import com.area.cth.service.DealService;
import com.area.cth.utils.ThreadLocalUtil;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;
import java.util.Map;

/**
 * @author 1
 * @description 针对表【deal】的数据库操作Service实现
 * @createDate 2024-10-16 09:26:39
 */

@Service
public class DealServiceImpl extends ServiceImpl<DealMapper, Deal>
        implements DealService {
    @Autowired
    private DealMapper dealMapper;

    @Override
    public List<Deal> getBuyerMyDealList() {
        Map<String, Object> map = ThreadLocalUtil.get();
        Integer id = (Integer) map.get("id");
        return dealMapper.getBuyerMyDealList(id);
    }

    @Override
    public List<Deal> getSellerMyDealList() {
        Map<String, Object> map = ThreadLocalUtil.get();
        Integer id = (Integer) map.get("id");
        return dealMapper.getSellerMyDealList(id);
    }

    @Override
    public IPage<Deal> dealList(Integer pageNo, Integer pageSize) {
        Page<Deal> page = Page.of(pageNo, pageSize);
        IPage<Deal> pb = dealMapper.dealList(page);
        return pb;
    }
}
